package week_02.entertaining_diversions.one_dimensional;

import java.util.ArrayList;
import java.util.Arrays;

public class one_dimensional {
    public static void main(String[] args) {
        //随机生成一个1-3的随机数

        Integer[] a=new Integer[10];
        for (int i=0;i<10;i++){
            a[i]=i+1;
        }
        ArrayList<Integer> light=new ArrayList<>();
        ArrayList<Integer> lightS=new ArrayList<>();
        light.addAll(Arrays.asList(a));
        ArrayList<Integer> light_correct=(ArrayList<Integer>)light.clone();
        int num=0;
     do {
            double random=(Math.random()*3);
            int r=(int)random;
            if (r%2==0){
//                for(int i=r;i>0;i--){
                    //偶数右移
                    int temp;
                    temp=light.get(9);
                    light.remove(9);
                    lightS.removeAll(lightS);
                    lightS.addAll(light);
                    light.removeAll(light);
                    light.add(temp);
                    light.addAll(lightS);
//                }

            }else {
                //单数左移
                int temp;
                temp=light.get(0);
                light.remove(0);
                light.add(temp);
            }
         System.out.println(light);
        num++;

        }while (!light_correct.equals(light));
        System.out.println(num);
//        System.out.println(light);
    }
}
